package com.lottery.material.service.admin.system.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lottery.material.dao.system.UserMapper;
import com.lottery.material.pojo.page.Page;
import com.lottery.material.pojo.page.PageData;
import com.lottery.material.pojo.system.User;
import com.lottery.material.service.admin.system.UserService;

/**
 * @description 系统用户服务接口实现类
 * @author rambo
 * @date 2018年6月7日 下午5:37:01
 */
@Service
public class UserServiceImpl implements UserService {

	@Autowired
	private UserMapper userMapper;

	/**
	 * @description 登录判断
	 * @param pd
	 * @return
	 * @throws Exception
	 */
	@Override
	public PageData getUserByNameAndPwd(PageData pd) throws Exception {
		return userMapper.getUserInfo(pd);
	}

	/**
	 * @description 更新登录时间
	 * @param pd
	 * @throws Exception
	 */
	@Override
	public void updateLastLogin(PageData pd) throws Exception {
		userMapper.updateLastLogin(pd);
	}

	/**
	 * @description 通过用户ID获取用户信息和角色信息
	 * @param USER_ID
	 * @return
	 * @throws Exception
	 */
	@Override
	public User getUserAndRoleById(String USER_ID) throws Exception {
		return userMapper.getUserAndRoleById(USER_ID);
	}

	/**
	 * @description 通过USERNAEME获取数据
	 * @param pd
	 * @return
	 * @throws Exception
	 */
	@Override
	public PageData findByUsername(PageData pd) throws Exception {
		return userMapper.findByUsername(pd);
	}

	/**
	 * @description 列出某角色下的所有用户
	 * @param pd
	 * @return
	 * @throws Exception
	 */
	@Override
	public List<PageData> listAllUserByRoldId(PageData pd) throws Exception {
		return userMapper.listAllUserByRoldId(pd);
	}

	/**
	 * @description 保存用户IP
	 * @param pd
	 * @throws Exception
	 */
	@Override
	public void saveIP(PageData pd) throws Exception {
		userMapper.saveIP(pd);
	}

	/**
	 * @description 用户列表
	 * @param page
	 * @return
	 * @throws Exception
	 */
	@Override
	public List<PageData> listUsers(Page page) throws Exception {
		return userMapper.userListPage(page);
	}

	/**
	 * @description 通过邮箱获取数据
	 * @param pd
	 * @return
	 * @throws Exception
	 */
	@Override
	public PageData findByUE(PageData pd) throws Exception {
		return userMapper.findByUE(pd);
	}

	/**
	 * @description 通过编号获取数据
	 * @param pd
	 * @return
	 * @throws Exception
	 */
	@Override
	public PageData findByUN(PageData pd) throws Exception {
		return userMapper.findByUN(pd);
	}

	/**
	 * @description 通过id获取数据
	 * @param pd
	 * @return
	 * @throws Exception
	 */
	@Override
	public PageData findById(PageData pd) throws Exception {
		return userMapper.findById(pd);
	}

	/**
	 * @description 保存用户
	 * @param pd
	 * @throws Exception
	 */
	@Override
	public void saveU(PageData pd) throws Exception {
		userMapper.saveU(pd);
	}

	/**
	 * @description 修改用户
	 * @param pd
	 * @throws Exception
	 */
	@Override
	public void editU(PageData pd) throws Exception {
		userMapper.editU(pd);
	}

	/**
	 * @description 删除用户
	 * @param pd
	 * @throws Exception
	 */
	@Override
	public void deleteU(PageData pd) throws Exception {
		userMapper.deleteU(pd);
	}

	/**
	 * @description 批量删除用户
	 * @param USER_IDS
	 * @throws Exception
	 */
	@Override
	public void deleteAllU(String[] USER_IDS) throws Exception {
		userMapper.deleteAllU(USER_IDS);
	}

	/**
	 * @description 用户列表(全部)
	 * @param USER_IDS
	 * @throws Exception
	 */
	@Override
	public List<PageData> listAllUser(PageData pd) throws Exception {
		return userMapper.listAllUser(pd);
	}

	/**
	 * @description 获取总数
	 * @throws Exception
	 */
	@Override
	public PageData getUserCount() throws Exception {
		return userMapper.getUserCount();
	}

	/**
	 * @description 获取所有用户
	 * @return
	 * @throws Exception
	 */
	@Override
	public List<User> getListUser() throws Exception {
		return userMapper.getListUser();
	}

}
